<template>
  <el-dialog :title="ids == 1 ? '问题详情' : '修改报告'" :close-on-click-modal="false" append-to-body :visible.sync="visible"
    lock-scroll width="600px">
    <el-row :gutter="15" class="" v-loading="loading">
      <el-form ref="elForm" :model="dataForm" :rules="rules" size="small" label-width="100px" label-position="right">
        <template>
          <el-col :span="24">
            <el-form-item label="维护保养内容" prop="systemName">
              <div>{{ dataForm.systemName }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="设备" prop="systemDeviceName">
              <div>{{ dataForm.systemDeviceName }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检查项" prop="deviceItemName">
              <div>{{ dataForm.deviceItemName }} </div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="地址" prop="buildingFloorName">
              <div> {{ dataForm.buildingFloorName }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="现场存在问题" prop="content">
              <div v-if="ids == 1"> {{ dataForm.content }}</div>
              <el-input type="textarea" :rows="2" v-model="dataForm.content" placeholder="请输入现场存在问题" v-else />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="现场照片" prop="photo">
              <ImageUpload v-if="ids == 1" v-model="dataForm.photo" :limit="10" :isShowTip="false" :isState="false"
                disabled />
              <ImageUpload v-else v-model="dataForm.photo" :limit="10" :isShowTip="false" :isState="false" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <div v-if="ids == 1"> {{ dataForm.remark }}</div>
              <el-input v-else v-model="dataForm.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>

        </template>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer" v-if="ids != 1">
      <el-button @click="visible = false"> 取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading"> 确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getEnterpriseInfo, putEnterprise } from "@/api/enterprise/index";
import { updateOrgReport } from "@/api/system/report";
export default {
  dicts: ["sys_normal_disable", "sys_user_sex"],
  data() {
    return {
      dataFormSubmitType: 0,
      continueBtnLoading: false,
      index: 0,
      visible: false,
      loading: false,
      btnLoading: false,
      dataForm: {},
      ids: 1,
      rules:
        {},
    }
  },
  methods: {
    clearData() {
      this.dataForm.systemName = ''
      this.dataForm.systemDeviceName = '';
      this.dataForm.deviceItemName = '';
      this.dataForm.buildingFloorName = '';
      this.dataForm.content = '';
      this.dataForm.photo = '';
      this.dataForm.remark = '';
      this.ids = 1

    },
    init(row, ids) {

      this.dataForm.id = row.id || 0;
      this.visible = true;
      this.clearData()
      this.$nextTick(() => {
        this.ids = ids
        if (this.dataForm.id) {
          this.loading = true
          this.dataForm = { ...row }
          this.loading = false
        }
      });
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs['elForm'].validate((valid) => {
        if (valid) {
          this.btnLoading = true
          updateOrgReport(this.dataForm).then(res => {
            this.visible = false
            this.btnLoading = false
            this.$emit('refreshDetailList', true)
          })
        }
      })
    },

    getUrl(url) {
      if (url) {
        let arr = url.split(',')
        // return process.env.VUE_APP_WEBSC_API + url
        return process.env.VUE_APP_WEBSC_API + arr[0]
      }

    },
  },
}

</script>
<style lang="scss" scoped>
.ellipsisList {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  /* 控制最多显示3行文字 */
  overflow: hidden;
  text-overflow: ellipsis;
}

#allMap {
  width: 100%;
  height: 450px;
}

.inMapSty {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 999999;
  opacity: 0.8;
  display: flex;
  height: 36px;

}
</style>
